/**
/* Copyright (C) 2011, Catdroid, Bernat Borras
/* 
/* This program is free software; you can redistribute it and/or
/* modify it under the terms of the GNU General Public License
/* as published by the Free Software Foundation in its version 2
/* of the License.
/* 
/* This program is distributed in the hope that it will be useful,
/* but WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/* GNU General Public License for more details.
/*
/* You should have received a copy of the GNU General Public License
/* along with this program; if not, write to the Free Software
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
/* 
/* @author Bernat Borras (@bbpp)
 */

package com.curs.catdroid_demo_life_2;

import java.util.List;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to one
 * of the primary sections of the app.
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {

	List<MiDato> datos;

	public SectionsPagerAdapter(FragmentManager fm, List<MiDato> mDatos) {
		super(fm);
		datos = mDatos;
	}

	
	/**
	 * Devuelve el fragment que vamos a ver
	 */
	@Override
	public Fragment getItem(int i) {
		ImageFragment fragment = new ImageFragment();
		Bundle args = new Bundle();		
		args.putLong(ImageFragment.ARG_ID, datos.get(i).getId());
		fragment.setArguments(args);
		return fragment;
	}

	@Override
	public int getCount() {
		return datos.size();
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return datos.get(position).getNombre();
	}
}